var web_prefix = '/'

const USER_TOKEN='template_token'

function imgPath(path){
    return '/common/download?name=' + path
}

 function getToken() {
  return Cookies.get(USER_TOKEN)
}

 function setToken(token) {
  return Cookies.set(USER_TOKEN, token)
}

function removeToken() {
  return Cookies.remove(USER_TOKEN)
}

/**
 * 判断是否登录
 */
function isLogin(){
	const token=getToken()
	if(!token){ 
		window.requestAnimationFrame(()=>{
		  window.location.href= '/page/login.html'
		})
	} 
}

/**
 * 如果有令牌，跳转到user.html页面
 */
function checkTokenJumpToUser(){
	const token=getToken()
	if(token){
		window.requestAnimationFrame(()=>{
		  window.location.href= '/page/user.html'
		})
	} 
}

//将url传参转换为数组
function parseUrl(url) {
    // 找到url中的第一个?号
    var parse = url.substring(url.indexOf("?") + 1),
        params = parse.split("&"),
        len = params.length,
        item = [],
        param = {};

    for (var i = 0; i < len; i++) {
        item = params[i].split("=");
        param[item[0]] = item[1];
    }

    return param;
}

